package nf.com.crud.dao.impl;

import nf.com.crud.dao.Test2Dao;
import nf.com.crud.entity.Test2;

import java.util.List;

public class Test2DaoImpl implements Test2Dao {
    QueryRunnerWrapper queryRunner=new QueryRunnerWrapper();
    @Override
    public List<Test2> getAll() {
        String sql="select id,uname from test2";
        return queryRunner.query(sql,Test2.class,null);
    }

    @Override
    public int insert(Test2 test2) {
        String sql="insert into test2(id,uname) values(?,?)";
        int result=0;
        result= queryRunner.update(sql,test2.getId(),test2.getUname());
        return result;
    }

    @Override
    public int update(Test2 test2) {
        String sql="update test2 set uname=? where id=?";
        int result=0;
        result= queryRunner.update(sql,test2.getUname(),test2.getId());
        return result;
    }

    @Override
    public int delete(int id) {
        String sql="delete from test2 where id=?";
        int result=0;
        result= queryRunner.update(sql,id);
        return result;
    }

}
